<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| This file is where you may define all of the routes that are handled
| by your application. Just tell Laravel the URIs it should respond
| to using a Closure or controller method. Build something great!
|
*/

Route::group(['namespace' => 'Wechat', 'prefix' => 'wechat'], function(){

    Route::any('/', 'HomeController@index');
    Route::get('menu', 'HomeController@menu');
    Route::get('callback', 'HomeController@callback');

});


//必须关注
Route::group(['middleware' => ['wechat.base', 'wechat.subscribe']], function() {

    //开网模块
    Route::group(['prefix' => 'network', 'namespace' => 'Network'], function () {
        Route::get('/', 'RegisterController@index');
        Route::post('submit', 'RegisterController@submit');
        Route::get('phone', function () {
            return view('app.network.phone');
        });
    });

    //绑定模块
    Route::group(['prefix' => 'user', 'namespace' => 'User'], function () {
        Route::get('bind', 'BindController@show');
        Route::post('bind', 'BindController@bind');
        Route::get('code/{session}/{nonce}/{cookie?}', 'BindController@code')->name('code');
    });

    //必须关注并且绑定
    Route::group(['middleware' => ['wechat.bind']], function () {

        //抽奖页面
        Route::get('activity/lottery', 'Activity\LotteryController@index');

        //奖品对应后台
        Route::get('activity/lottery/admin', 'Activity\LotteryController@lotteryList');


        //图书模块
        Route::group(['prefix' => 'library', 'namespace' => 'Library'], function () {

            Route::get('/', 'HomeController@index');
            Route::get('detail/{id}', 'HomeController@detail');
            Route::post('search', 'HomeController@search');
            Route::post('location', 'HomeController@location');
            Route::get('reader', 'ReaderController@detail');
        });

        //维护模块
        Route::group(['prefix' => 'repair'], function () {

            Route::get('/', 'Repair\RepairController@getView')->name('repair');
            Route::post('create', 'Repair\RepairController@addRepair')->name('addrepair');
            Route::post('cancel', 'Repair\RepairController@cancelRepair')->name('cancelrepair');
            Route::post('feedback/create', 'Operation\FeedbackController@repairFeedback')->name('addfeedback');

        });

        //失物模块
        Route::group(['prefix' => 'lost', 'namespace' => 'Lost'], function(){
            Route::get('/', 'HomeController@index');
            Route::get('list', 'HomeController@list')->name('lost.list');
            Route::get('qrCode', 'UserController@qrCode')->name('lost.code');
            Route::post('mine', 'UserController@index')->name('lost.mine');

            Route::post('publish', 'PublishController@publish')->name('lost.publish');

            Route::post('release', 'AuditController@release')->name('lost.release');
            Route::get('scan/{id}', 'AuditController@index')->name('lost.scan');
            Route::get('pending', 'AuditController@list')->name('lost.pending');
            Route::post('audit', 'AuditController@audit')->name('lost.audit');
//        Route::get('info', 'AuditController@index')
        });

        Route::group(['prefix' => 'traffic', 'namespace' => 'Traffic'], function(){
            Route::get('/', 'HomeController@index');
            Route::get('iphone', 'HomeController@iphone');
        });

    });

});

//错误页面
    Route::get('error/{param}', function($param){
        return view('errors/' . $param);
    });

//权益页面
Route::group(['prefix'=>'equity','namespace'=>'equity'],function(){
    Route::get('/cos',"DisplayController@index");
    Route::post("/test",'DisplayController@request');
    Route::get("/test2","QueryidController@query");
    Route::post("/digister",'QueryidController@login');
    Route::get('kit/captcha/{tmp}', 'KitController@captcha');
});
    Auth::routes();
  

//管理模块
Route::group(['prefix' => 'admin', 'namespace' => 'Admin', 'middleware' => ['auth', 'admin.login']], function(){


    Route::get('/', 'HomeController@index');

    //权限模块
    Route::group(['prefix' => 'permission', 'namespace' => 'Permission'], function(){

        Route::resource('role', 'RoleController', ['only' => [
            'index', 'destroy', 'store'
        ]]);

        Route::resource('admin', 'AdminController', ['only' => [
            'index', 'destroy', 'store'
        ]]);

        Route::resource('permission', 'PermissionController', ['only' => [
            'index', 'destroy', 'store'
        ]]);

        Route::resource('role-user', 'RoleUserController');

        Route::resource('permission-role', 'PermissionRoleController');

    });

    Route::group(['prefix' => 'operation', 'namespace' => 'Operation'], function(){
        Route::group(['prefix' => 'template'], function(){

            Route::get('/', 'TemplateController@index');

        });
    });

    Route::group(['prefix' => 'user', 'namespace' => 'User'], function(){

        Route::group(['prefix' => 'exception'], function(){

            Route::get('/', 'ExceptionController@index');
            Route::get('getForm/{id}', 'ExceptionController@getForm');
            Route::get('code/{session}/{nonce}/{cookie?}', 'ExceptionController@code');
            Route::post('bind', 'ExceptionController@bind');

        });

        Route::get('/list', 'HomeController@index');
        Route::post('{id}', 'HomeController@updateUSer');



    });

    Route::group(['prefix' => 'password', 'namespace' => 'Auth'], function(){
        Route::get('reset', 'ResetPasswordController@index');
        Route::post('reset', 'ResetPasswordController@reset');
    });

});